﻿using System;
using System.Linq;

namespace NativeCode.Core.Extensions
{
	/// <summary>
	/// Mapping classes are dumb but necessary. :(
	/// </summary>
	public static class TypeCodeExtensions
	{
		public static TypeCode[] All = new[]
		{
			TypeCode.Boolean,
			TypeCode.Byte,
			TypeCode.Char,
			TypeCode.DateTime,
			TypeCode.DBNull,
			TypeCode.Decimal,
			TypeCode.Double,
			TypeCode.Empty,
			TypeCode.Int16,
			TypeCode.Int32,
			TypeCode.Int64,
			TypeCode.Object,
			TypeCode.SByte,
			TypeCode.Single,
			TypeCode.String,
			TypeCode.UInt16,
			TypeCode.UInt32,
			TypeCode.UInt64,
		};

		public static TypeCode[] Numerics = new[]
		{
			TypeCode.Byte,
			TypeCode.Decimal,
			TypeCode.Double,
			TypeCode.Int16,
			TypeCode.Int32,
			TypeCode.Int64,
			TypeCode.SByte,
			TypeCode.Single,
			TypeCode.UInt16,
			TypeCode.UInt32,
			TypeCode.UInt64,
		};

		public static TypeCode[] Inequaliable = new[]
		{
			TypeCode.Byte,
			TypeCode.Char,
			TypeCode.DateTime,
			TypeCode.Decimal,
			TypeCode.Double,
			TypeCode.Int16,
			TypeCode.Int32,
			TypeCode.Int64,
			TypeCode.SByte,
			TypeCode.Single,
			TypeCode.UInt16,
			TypeCode.UInt32,
			TypeCode.UInt64,
		};

		public static bool IsNumeric(this TypeCode typeCode)
		{
			return Numerics.Contains(typeCode);
		}

		public static bool CanCompareInequality(this TypeCode typeCode)
		{
			return Inequaliable.Contains(typeCode);
		}
	}
}